#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e7 + 5;

int n, m;
int a[N];
int mnp[N], phi[N], primes[N], tot;
ll ans[N];
void init(int n) {
  mnp[1] = 1, phi[1] = 1;
  rep(i, 2, n) {
    if (!mnp[i]) primes[++tot] = i, mnp[i] = i, phi[i] = i - 1;
    rep(j, 1, tot) {
      ll k = 1ll * primes[j] * i;
      if (k > n) break;
      mnp[k] = primes[j];
      if (i % primes[j] == 0) {
        phi[k] = primes[j] * phi[i];
        break;
      } else
        phi[k] = (primes[j] - 1) * phi[i];
    }
  }
  ans[1] = 1;
  rep(i, 2, n) {
    int x = mnp[i], y = i / x;
    if (y % x == 0) {  // 不互质
      ans[i] = ans[y];
      while (y % mnp[i] == 0) x *= mnp[i], y /= mnp[i];
      ans[i] += 1ll * phi[x] * x * ans[y];
    } else {
      ans[i] = (1 + 1ll * phi[x] * x) * ans[y];
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  init(2e7);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    cout << (ans[n] + 1) / 2 << endl;
  }
  return 0;
}
